
import axios from "axios";

type SendFlipParams = {
  memberId: string;
  content: string;
  type: number;
  cost: string;
  answerType: number;
}
export const sendFlip = async (
  pToken: string,
  params: SendFlipParams
) => {
    const { memberId, content, type, cost, answerType } = params;
  let config = {
    method: "post",
    maxBodyLength: Infinity,
    url: "https://pocketapi.48.cn/idolanswer/api/idolanswer/v1/user/question",
    headers: {
      host: "pocketapi.48.cn",
      "content-type": "application/json;charset=utf-8",
      appinfo:
        '{"vendor":"apple","deviceId":"D6193A0F-656F-4D8A-AB0C-005B9339FA08","appVersion":"7.1.24","appBuild":"25041301","osVersion":"16.2.0","osType":"ios","deviceName":"iPhone 14","os":"ios"}',
      accept: "*/*",
      pa: "MTc1MzY5MDE2NDAwMCw3OTY2LDY5N0Y1OTk0QTk3MjAwODRFNUIwNDAwMkE2OUNEMEFFLA==",
      "accept-language": "zh-Hans-CN;q=1",
      "p-sign-type": "V0",
      token: pToken,
      "user-agent": "PocketFans201807/7.1.24 (iPhone; iOS 16.2; Scale/3.00)",
    },
    data: {"memberId":memberId,"content":content,"type":type,"cost":cost,"answerType":answerType},
  };
  try {
    const res = await axios.request(config);
    if (res.data.content) return res.data.content;
    return false;
  } catch (error) {
    return false;
  }
};
